package net.java.dev.jugbrescia.test.xml.model;

import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

@XStreamAlias("lib:book")
public class Book
{
	@XStreamAsAttribute
	private String title = "";
	@XStreamAlias("lib:authors")
	private List<Author> authors;
	public Book()
	{
		this.authors = new ArrayList<Author>();
	}
	public Book(final String title)
	{
		this.title = title;
		this.authors = new ArrayList<Author>();
	}
	public List<Author> getAuthors()
	{
		return authors;
	}
	public String getTitle()
	{
		return title;
	}
	public void addAuthor(final Author author)
	{
		this.authors.add(author);
	}
	public String toString()
	{
		return new StringBuffer(this.title).append(" - ").append(this.authors.toString()).toString();
	}
}